package day_04;

import java.util.Scanner;

/**
 * @ClassName Test03
 * @Description TODO
 * @Author hp
 * @Date 2021/6/6 8:30
 * @Version 1.0
 **/
public class Test03 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //进行日期的输入
        System.out.println("请输入一个日期:");
        System.out.println("请输入年:");
        int year = in.nextInt();
        System.out.println("请输入月:");
        int month = in.nextInt();
        System.out.println("请输入日:");
        int day = in.nextInt();
        //声明旗帜变量判断记录日期是否有误
        boolean flag = false;
        boolean flag1 = true;
        if (year<=0||month<1||month>12){
            flag1 = false;
        }

        if (month == 2) {
            /*判断是否为闰年*/
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                if (day >= 1 && day <= 29) {
                    flag = true;
                }
            } else {
                if (day >= 1 && day <= 28) {
                    flag = true;
                }
            }

        } else if (month == 1 || month == 3 || month == 5 || month == 8 || month == 7 || month == 10 || month == 12)
        {
            if (day >= 1 && day <= 31) {
                flag = true;
            }
        }else {
            if(day>=1&&day<=30){
                flag = true;
            }
        }
        /*根据旗帜变量判断是否日期有误，并输出结果*/
        if (flag && flag1){
            System.out.println(year+"年"+month+"月"+day+"日");
        }else {
            System.out.println("日期有误");
        }
    }


}
